package com.demo.domain;

import java.util.Date;

import javax.annotation.Resource;

import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.type.JdbcType;

@Resource
public class Blog {
	private Integer id;

	private String title;

	private Date publishtime;

	private String content;

	public void setId(Integer id) {
		this.id = id;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public void setPublishtime(Date publishtime) {
		this.publishtime = publishtime;
	}

	public void setContent(String content) {
		this.content = content;
	}

	// call identity()
	// SELECT LAST_INSERT_ID()
	@Result(id = true)
	@SelectKey(statement = "SELECT LAST_INSERT_ID()", before = false, keyProperty = "id", keyColumn = "id", resultType = Integer.class)
	public Integer getId() {
		return id;
	}

	@Result
	public String getTitle() {
		return title;
	}

	@Result(jdbcType=JdbcType.TIMESTAMP)
	public Date getPublishTime() {
		return publishtime;
	}

	@Result
	public String getContent() {
		return content;
	}
}